package com.xhg.xhgone.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

import javax.sql.DataSource;

@SpringBootConfiguration
@EnableTransactionManagement
public class TransactionManagementConfiguration implements TransactionManagementConfigurer {

  @Autowired private DataSource dataSource;

  public PlatformTransactionManager annotationDrivenTransactionManager() {

    return new DataSourceTransactionManager(dataSource);
  }
}
